'use strict';

/**
 * Module dependencies.
 */
var mongoose = require('mongoose'),
	Schema = mongoose.Schema;

/**
 * Sessions Schema
 */
var SynchupsAndSessionsSchema = new Schema({
	title: {
		type: String,
		default: '',
		trim: true,
		required: 'Title cannot be blank'
	},
	content: {
		type: String,
		default: '',
		trim: true
	},
	attachments:[],
	duration: {
		type: Number,
		default: '0.0',
		max: 10,
		required: 'Duration of the session should be defined'
	},
	presenters: [{
		userId: {
			type: Schema.ObjectId,
			ref: 'User'
		},
		rating:[{
			ratedBy:{
				type: Schema.ObjectId,
				ref: 'User'
			},
			rating: {
				type: Number,
				default: '0.0'
			},
			ratedOn: {
				type: Date,
				default: Date.now
			}
		}]
	}],
	group:{
		type: Schema.ObjectId,
		ref: 'Groups',
		required: 'Session should belong to a group'
	},
	created: {
		type: Date,
		default: Date.now,
		required: 'Session should have created date'
	},
	createdBy: {
		type: Schema.ObjectId,
		ref: 'User'
	},
	scheduledOn: {
		type: Date,
		default: Date.now,
		required: 'Session should be scheduled on same date'
	},

	startsOn:{
		type: Date,
		default: Date.now
	},
	endsOn:{
		type: Date,
		default: Date.now
	},

	audience: [{
		type: Schema.ObjectId,
		ref: 'User'

	}],
	isActive:Boolean
});

mongoose.model('SynchupsAndSessions', SynchupsAndSessionsSchema);
